package com.shadow.rpc
{
	import com.shadow.manager.ModuleManager;

	/**
	 * 通讯体
	 * @author Liseen
	 * 
	 */	
	public class RpcClient
	{
		public static var instance:RpcClient;
		
		
		private static const GET_INIT_GAME:String = "initGame";
		private static const INIT_GAME_RESPONSE:String = "initGameResponse";
		
		public function RpcClient(value:Singel)
		{
			
		}
		
		public static function getInstance():RpcClient {
			if (instance==null) {
				instance = new RpcClient(new Singel());
			}
			return instance;
		}
		
		/**
		 *获取初始化数据 
		 * @param fun	数据返回成功后的回调处理
		 * 
		 */		
		public function getInitData(fun:Function):void
		{
			var userInfo:Object = new Object();
			userInfo.user = GlobalContext.flashVars.userID;
			userInfo.hashCode = GlobalContext.flashVars.hashCode;
			userInfo.registerTime = GlobalContext.flashVars.registerTime;
			
			var rpcRequest:RpcRequest = new RpcRequest(GET_INIT_GAME,userInfo,fun,null);
		}
		
		/**
		 *服务器响应 
		 * @param responseObj
		 * @param callBack
		 * 
		 */		
		public function rpcResponse(responseObj:Object, callBack:Function=null):void
		{
			switch(responseObj.response){
				
				case INIT_GAME_RESPONSE:
					ModuleManager.getInstance().setInitialData(responseObj);
					callBack();
					break;
				
			}
		}
			
		
	}
}

class Singel {
	
}